package com.jzy.gulimall.search.controller;

import com.jzy.common.to.es.BrandEsTo;
import com.jzy.common.utils.R;
import com.jzy.gulimall.search.service.ElasticUpdateService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @author jzy
 * @date 2020/9/14 21:15
 */
@RestController
@RequestMapping("/search/update")
public class ElasticUpdateController {

    @Resource
    private ElasticUpdateService elasticUpdateService;

    /**
     * 修改品牌表 更新es中的数据
     */
    @PostMapping("/brand")
    public R updateEsBrand(@RequestBody BrandEsTo brand) {
        try {
            elasticUpdateService.updateEsBrand(brand);
            return R.ok();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return R.error();
    }
}
